﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using U9API.JsonModel;
using U9API.Pub;

namespace Test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Button1_Click(object sender, EventArgs e)
        {
            U9API.JsonModel.ApiCustomer model = new ApiCustomer();
            model.Sites = new List<SitesItem>();
            SitesItem Site = new SitesItem();
            Site.Code = "testsitecode";
            Site.Name = "testsitename";
            model.Sites.Add(Site);
            edtOutPut.Text = model.ToJson();
        }

        private void Button2_Click(object sender, EventArgs e)
        {
            string strjson = edtOutPut.Text;
            if (!string.IsNullOrEmpty(strjson))
            {
                try
                {
                    U9API.JsonModel.ApiCustomer model = JsonConvert.DeserializeObject<U9API.JsonModel.ApiCustomer>(strjson); //Common.FromJson<U9API.JsonModel.ApiCustomer>(strjson);
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                
            }
            
        }
    }
}
